-
Notifications
You must be signed in to change notification settings - Fork 320
Initial C Bindings for Cosmos DB SDK for Rust #3347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
4393c1b to
aeaba92
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces C bindings for the Azure Cosmos DB SDK for Rust, allowing the SDK to be used from C and other languages. Key changes include:
- New FFI layer with runtime context, call context, and error handling infrastructure
- C bindings for CosmosClient, DatabaseClient, and ContainerClient
- Support for CRUD operations, queries, and resource management
- Auto-generated C header file (
azurecosmos.h) - Comprehensive C test suite covering CRUD operations, error handling, and memory management
Reviewed Changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/string.rs |
String utilities and FFI string conversion helpers |
src/runtime/tokio.rs |
Tokio runtime wrapper for async operations |
src/runtime/mod.rs |
Runtime context FFI functions |
src/options/mod.rs |
Empty option structs for future extensibility |
src/lib.rs |
Main library entry, version function, and tracing setup |
src/error.rs |
Error types, codes, and conversion from Azure SDK errors |
src/context.rs |
Call context for FFI operations and helper macros |
src/clients/mod.rs |
Client module exports |
src/clients/database_client.rs |
Database operations FFI functions |
src/clients/cosmos_client.rs |
Cosmos client creation and database operations |
src/clients/container_client.rs |
Container and item operations FFI functions |
include/azurecosmos.h |
Auto-generated C header file |
c_tests/*.c |
C test suite for FFI functionality |
build.rs |
cbindgen configuration for header generation |
Cargo.toml |
Dependencies and features for native bindings |
CMakeLists.txt |
CMake build configuration for C tests |
Comments suppressed due to low confidence (1)
sdk/cosmos/azure_data_cosmos_native/src/string.rs:37
- The
safe_cstring_newfunction callsexpect()which can panic, but this panic behavior is not documented. Add a# Panicssection to the function documentation explaining when this function panics (when the string contains interior NUL bytes).
This PR ports over the initial C bindings, contributed by a partner team, to this repository.
The bindings are defined in the
azure_data_cosmos_nativecrate, which buildslibazurecosmos.aandlibazurecosmos.so(and others on other platforms). That project also creates theazurecosmos.hheader file.